<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>轮播图</title>
    <style>
        .Main{
            width: 600px;
            height: 250px;
            margin: auto;
        }
    </style>
</head>
<body>
<div class="Main"><img src="img/1.jpg" alt="这是一张图片"></div>
<script>
    let img=document.querySelector('img');
    let arrI=["img/1.jpg","img/2.jpg","img/3.jpg","img/4.jpg","img/5.jpg"];
    let i=0;
    setInterval(function (){
        if(i>4){
            i=0;
        }else{
            ++i;
            img.src=arrI[i];
        }
    },500)
</script>
</body>
</html>